package effective_java.design_pattern.command;


import java.util.Map;

/**
 * 具体命令者
 *
 * @author Verlet
 * @date 2023-09-30 17:01
 */
public class OrderCommand implements Command {
    // 持有接受者对象
    private SeniorChef receiver;
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable()+"桌的订单:");
        for(Map.Entry<String, Integer> entry : order.getFoodDic().entrySet()){
            receiver.makeFood(entry.getValue(),entry.getKey());
        }
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(order.getDiningTable()+"桌的饭弄好了。");
    }
}
